#pragma once
#include <map>
using namespace std;

#include "badiff.h"
#include "fadiff.h"


#define OVERFLOW	(double) 20000.0f
#define UNDERFLOW	(double) -20000.0f
#define INTERVALMIN	(double)-1.0f
#define INTERVALMAX	(double) 1.0f
#define INFINITY_GRADE  (double)20000.0f
#define TOL_0		(double) 0.0001f



class BoundedFunctionPoints : public map <double, F<double>* >{

protected:
		double XRangeMin;
		double XRangeMax;
		double step;
		size_t IntervalsNum;

public:
	typedef pair< map <double, F<double>* >::iterator, map <double, F<double>* >::iterator > BoundedInterval;

public:
		double x(size_t) const;
		F<double>* Fx(size_t);
		size_t PointsNum( ) const{return IntervalsNum + 1;};

public:
		void setValueAtPoint(double,  F<double>* );
		F<double>* getValueAtPoint( double );

	
public:
		void draw( ) const;

	public:
		BoundedFunctionPoints(double Rmin, double Rmax, size_t IntNum=1);
		virtual ~BoundedFunctionPoints(void);
	};


class BoundedFunctionDescription : public BoundedFunctionPoints{

	    
public:
		typedef BoundedFunctionDescription* pointer;
		typedef F<double> (*Evaluate)(F<double> Xval);
		typedef pair<Evaluate, string> FuncRep;

protected:	
		string Syntax;
		Evaluate EvalFunc;
		F<double>* makeBehave(F<double> y);
	

	

public:
	BoundedFunctionDescription(FuncRep, double=-1.0, double=1.0, size_t =100);
	~BoundedFunctionDescription( );

};